package lanqiao;
/**
 * @Project : ProgrammingExercises
 * @Package : LanQiao.PrepareForCompetition
 * @File : Q0103.java
 * @Author : WangRuoyu
 * @Date : 2023/3/16 10:48
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q0103 {

    static int[] days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    static boolean check(int year, int month, int day) {
        if (month < 1 || month > 12) {
            return false;
        }
        if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
            if (month == 2) {
                return day >= 1 && day <= 29;
            }
        }
        return day >= 1 && day <= days[month];
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split("/");
        int w1 = Integer.parseInt(words[0]);
        int w2 = Integer.parseInt(words[1]);
        int w3 = Integer.parseInt(words[2]);

        if (w1 == w2 && w2 == w3) {
            int a;
            String sa = "";
            if (w1 < 60) {
                if (check(2000 + w1, w2, w3)) {
                    a = ((2000 + w1) * 100 + w2) * 100 + w3;
                    sa = String.valueOf(a);
                    System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                }
            } else {
                if (check(1900 + w1, w2, w3)) {
                    a = ((1900 + w1) * 100 + w2) * 100 + w3;
                    sa = String.valueOf(a);
                    System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                }
            }
        } else if (w1 == w2 || w1 == w3) {
            int a = 0;
            int b = 0;
            String sa = "";
            String sb = "";

            if (w1 < 60) {
                if (check(2000 + w1, w2, w3)) {
                    a = ((2000 + w1) * 100 + w2) * 100 + w3;
                    sa = String.valueOf(a);
                }
            } else {
                if (check(1900 + w1, w2, w3)) {
                    a = ((1900 + w1) * 100 + w2) * 100 + w3;
                    sa = String.valueOf(a);
                }
            }

            if (w3 < 60) {
                if (check(2000 + w3, w1, w2)) {
                    b = ((2000 + w3) * 100 + w1) * 100 + w2;
                    sb = String.valueOf(b);
                }
            } else {
                if (check(1900 + w3, w1, w2)) {
                    b = ((1900 + w3) * 100 + w1) * 100 + w2;
                    sb = String.valueOf(b);
                }
            }

            if (a < b) {
                if (a != 0) {
                    System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                }
                if (b != 0) {
                    System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                }
            } else {
                if (b != 0) {
                    System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                }
                if (a != 0) {
                    System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                }
            }
        } else {
            int a = 0;
            int b = 0;
            int c = 0;
            String sa = "";
            String sb = "";
            String sc = "";

            if (w1 < 60) {
                if (check(2000 + w1, w2, w3)) {
                    a = ((2000 + w1) * 100 + w2) * 100 + w3;
                    sa = String.valueOf(a);
                }
            } else {
                if (check(1900 + w1, w2, w3)) {
                    a = ((1900 + w1) * 100 + w2) * 100 + w3;
                    sa = String.valueOf(a);
                }
            }

            if (w3 < 60) {
                if (check(2000 + w3, w1, w2)) {
                    b = ((2000 + w3) * 100 + w1) * 100 + w2;
                    sb = String.valueOf(b);
                }
                if (check(2000 + w3, w2, w1)) {
                    c = ((2000 + w3) * 100 + w2) * 100 + w1;
                    sc = String.valueOf(c);
                }
            } else {
                if (check(1900 + w3, w1, w2)) {
                    b = ((1900 + w3) * 100 + w1) * 100 + w2;
                    sb = String.valueOf(b);
                }
                if (check(1900 + w3, w2, w1)) {
                    c = ((1900 + w3) * 100 + w2) * 100 + w1;
                    sc = String.valueOf(c);
                }
            }

            if (a != 0 && b != 0 && c != 0) {
                if (a < b) {
                    if (b < c) {
                        System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                        System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                        System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                    } else if (c < a) {
                        System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                        System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                        System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                    } else {
                        System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                        System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                        System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                    }
                } else {
                    if (a < c) {
                        System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                        System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                        System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                    } else if (c < b) {
                        System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                        System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                        System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                    } else {
                        System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                        System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                        System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                    }
                }

            } else if (a != 0 && b != 0) {
                if (b < a) {
                    System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                    System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                } else {
                    System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                    System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                }
            } else if (c != 0 && b != 0) {
                if (b < c) {
                    System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                    System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                } else {
                    System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                    System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
                }
            } else if (a != 0 && c != 0) {
                if (a < c) {
                    System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                    System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                } else {
                    System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
                    System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
                }
            } else if (a != 0) {
                System.out.println(sa.substring(0, 4) + "-" + sa.substring(4, 6) + "-" + sa.substring(6, 8));
            } else if (b != 0) {
                System.out.println(sb.substring(0, 4) + "-" + sb.substring(4, 6) + "-" + sb.substring(6, 8));
            } else if (c != 0) {
                System.out.println(sc.substring(0, 4) + "-" + sc.substring(4, 6) + "-" + sc.substring(6, 8));
            }
        }
    }
}
